package com.example.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.project.entity.Category;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CategoryMapper extends BaseMapper<Category> {
    
    @Select("SELECT * FROM categories WHERE status = 1 ORDER BY sort ASC")
    List<Category> selectEnabledCategories();
    
    @Select("SELECT COUNT(*) FROM products WHERE category_id = #{categoryId}")
    int countProductsByCategory(Long categoryId);
} 